define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
    //学段列表
    httpService.post(app.urls.stage_selectAll, {}, function (data) {
        if ("0000" === data.code) {
            $scope.stageList = data.data;
        } else {
            alert(data.msg);
        }
    });
    httpService.post(app.urls.grade_select,{"id":params.id},function(data){
		if("0000" === data.code){
			$scope.form = data.data[0];
		}else{
			alert(data.msg);
		}
	});
    $scope.saveForm = function(){
		if($scope.formCheck()){
			httpService.post(app.urls.grade_selectIfExit,$scope.form,function(data){
				if("0000" === data.code){
					if(data.data==0){
						httpService.post(app.urls.grade_update,$scope.form,function(data){
							if("0000" === data.code){
								eventBusService.publish("content.page.reload",data.data);
								eventBusService.publish("modal.page.close",{});
				    		}else{
				    			alert(data.msg);
				    		}
						});
					}else{
						alert("该年级已存在");
					}
	    		}else{
	    			alert(data.msg);
	    		}
			});
		}
	}
}}});